<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title></title>
    <meta charset="utf-8">
    <meta content="" name="description">
    <meta content="" name="keywords">
    <meta content="eric.wu" name="author">
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
    <meta content="no-cache" http-equiv="pragma">
    <meta content="0" http-equiv="expires">
    <meta content="telephone=no, address=no" name="format-detection">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
    <link rel="stylesheet" type="text/css" href="/sources/css/main.css">
    <link rel="stylesheet" type="text/css" href="/sources/css/dialog.css">
    <script src="/sources/js/jquery_min.js"></script>
    <script src="/sources/js/main.js"></script>
    <script src="/sources/js/helper_min.js"></script>
    <script src="/sources/js/dialog_min.js"></script>
    <script>
    function editNickName(thi, evt, app_id , uid){
        var d = new iDialog();
        d.open({
            classList: "default",
            title:"",
            close:"",
            content:'<form id="form_1" action="javascript:;" method="post">\
                <table class="table_input">\
                    <tr>\
                        <td>\
                            <input type="text" maxlength="10" name="nickName" class="input" value="'+thi.getAttribute('data-nickname')+'" autofocus="true" />\
                        </td>\
                    </tr>\
                </table>\
            </form>',
            btns:[
                {id:"", name:"确定", onclick:"fn.call();", fn: function(self){
                    var form1 = document.getElementById("form_1");
                    var obj = {
                            app_id : app_id,
                            uid : uid,
                        nickName: $.trim(form1.nickName.value)
                    }
                    if(obj.nickName.length<1){
                        alert("请输入用户名", 1500);
                        return;
                    }
                    loading(true);
                    $.ajax({
                        url: "{$site_info.route_base}/ajax/ajaxeditnickname",
                        type : "post",
                        data : obj,
                        dataType : "JSON",
                        success : function(res){
                            loading(false);
                            if(1 == res.result){
                                self.die();
                                alert("修改成功", 1500);
                                $("#nickName label").html(obj.nickName);
                                $("#nickName a").attr("data-nickname", obj.nickName);
                            }else{
                                alert("修改失败", 1500);
                            }
                        }
                    });
                }},
                {id:"", name:"取消", onclick:"fn.call();", fn: function(self){
                    self.die();
                }}
            ]
        });
    }


    function userOperate(thi, evt, typ, id){
        var n = -1;
        if(thi.classList.contains("on") ){
            n = 1;
        }
        var obj = {
            userId: 123334,
            type:typ,// collect, like
            n:n
        }
        loading(true);
        $.ajax({
            url: "data/userOperate.json",
            type:"post",
            data:obj,
            dataType:"JSON",
            success: function(res){
                loading(false);
                if(1 == res.result){
                    thi.querySelector("label").innerHTML = res.data.total;
                    thi.classList[n>0?"remove":"add"]("on");
                }else{
                    alert(res.message||"失败", 1500, function(){});
                }
            }
        });

    }


     function collectTrends(type, app_id, tid, uid){
            var args = arguments;
            loading(true);
            $.post('{$site_info.route_base}/ajax/collect',{
                "type" : type,
                "app_id"  : app_id,
                "tid"  : tid,
                "uid"  : uid,
                },function(res){
                    loading(false);
                    if("1" == res){
                    var $a = $("#collect_"+tid);
                    var label = $a.find("label")[0];
                    var total = parseInt(label.innerText );
                    $a[0==type?"addClass":"removeClass"]("on");
                    total = (0 == type)?total+1:total-1;
                    label.innerText = total;
                    $a.attr("onclick", 'collectTrends('+[1,0][type]+","+(Array.prototype.slice.call(args, 1).join(','))+');');
                    }
                });
        }
       function praiseTrends(type, app_id, tid, uid){
            var args = arguments;
            loading(true);
            $.post('{$site_info.route_base}/ajax/praise',{
                "type" : type,
                "app_id"  : app_id,
                "tid"  : tid,
                "uid"  : uid,
                },function(res){
                    loading(false);
                    if("1" == res){
                    var $a = $("#praise_"+tid);
                    var label = $a.find("label")[0];
                    var total = parseInt(label.innerText );
                    $a[0==type?"addClass":"removeClass"]("on");
                    total = (0 == type)?total+1:total-1;
                    label.innerText = total;
                    $a.attr("onclick", 'praiseTrends('+[1,0][type]+","+(Array.prototype.slice.call(args, 1).join(','))+');');
                    }
                });
        }
    </script>
</head>
<body onselectstart="return true;" ondragstart="return false;" class="discuss_my discuss_my_tiezi">
    <div id="container" class="container">
        <header>
            <div class="header_1">
                <ul class="tbox">
                    <li>
                        <span id="upload_header" class="head_img">
                            <img src="{$other_user_info.user_pic}">
                        </span>
                    </li>
                    <li>
                        <h5 id="nickName"><label>{$other_user_info.nick}</label><a href="javascript:void(0);" class="icons icons_edit">&nbsp;</a></h5>
                        <!--  
                        <p>
                            <a href="http://349257.m.weimob.com/Webnewmembercard/GetMember?pid={$site_info.app_id}&wechatid=okthVt76nHZp7-wt88ED7szslHvw" class="label">
                                <span class="icons icons_vip_0">&nbsp;</span>非会员
                            </a>
                        </p>
                         -->
                    </li>
                </ul>
            </div>
            <div class="header_2">
                <nav>
                    <ul class="box">
                        <li>
                            <a href="javascript:;" class="on">
                                <label>帖子</label>
                                <span>{$other_user_info.post_count}</span>
                            </a>
                        </li>
                        <li>
                            <a href="{$site_info.app_id}/index/collectlist?app_id={$site_info.app_id}">
                                <label>喜欢</label>
                                <span>{$other_user_info.like}</span>
                            </a>
                        </li>
                        <li>
                            <a href="{$site_info.app_id}/index/messagelist?app_id={$site_info.app_id}">
                                <label>消息</label>
                                <span>{$other_user_info.comment_count}</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </header>
        <div class="body">
            <div id="list_article" class="list_article">
                <foreach name="post_list" item="vo">
                <article>
                    <header>
                        <div class="article_state">
                            <span class="state1">审核通过</span>
                        </div>
                        <ul class="tbox">
                            <li></li>
                            <li>
                                <h5>{$vo.user_info.nick}</h5>
                                <p>{$vo.publish_time|date="Y-m-d H:i:s",###}</p>
                            </li>
                            <li>
                                <a href="{$site_info.route_base}/index/trendsrow?app_id={$site_info.app_id}&tid={$vo.id}" class="icons icons_edit">&nbsp;</a>
                            </li>
                        </ul>
                    </header>
                    <section>
                        <div>
                            <div>{$vo.intro}</div>
                        </div>
                        <a href="{$site_info.route_base}/index/commentlist?app_id={$site_info.app_id}&tid={$vo.id}">查看全文</a>
                    </section>
                    <footer>
                        <ul class="box">
                            <li>
                                <a href="javascript:;" class="a_collect <notempty name="vo.is_like">on</notempty>" id="collect_{$vo.id}" onclick="collectTrends({$vo.is_like}, {$site_info.app_id}, {$vo.id}, {$user_info.user_id});">
                                    <span class="icons icons_collect">&nbsp;</span><label>{$vo.like}</label>
                                </a>
                            </li>
                            <li>
                                <a href="{$site_info.route_base}/index/commentlist?app_id={$site_info.app_id}&tid={$vo.id}&uid=387016" class="a_comment">
                                    <span class="icons icons_comment">&nbsp;</span><label>{$vo.comment_count}</label>
                                </a>
                            </li>
                            <li>
                                <a href="javascript:;" class="a_like <notempty name="vo.is_laud">on</notempty>" id="praise_{$vo.id}" onclick="praiseTrends({$vo.is_laud}, {$site_info.app_id}, {$vo.id}, {$user_info.user_id});">
                                    <span class="icons icons_like">&nbsp;</span><label>{$vo.laud}</label>
                                </a>
                            </li>
                        </ul>
                    </footer>
                </article>
                </foreach>
            </div>
        </div>
        <footer>
            <section class="nav_footer">
                <ul class="box">
                    <li>
                        <a href="{$site_info.route_base}/index/index">
                            <span class="icons_home">&nbsp;</span>
                            <label>首页</label>
                        </a>
                    </li>
                    <li>
                        <a href="{$site_info.route_base}/index/newtrends/user_id/{$user_info.user_id}" class="nav_add">
                            <span class="icons_home_edit">&nbsp;</span>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:;" class="on">
                            <span class="icons_my">&nbsp;</span>
                            <label>我的</label>
                        </a>
                    </li>
                </ul>
            </section>
        </footer>
    </div>

<script>
$(document).ready(function(){
    
    var range = 50;             //距下边界长度/单位px  
    var pageNum = 2;  
    var totalheight = 0;   
    var main = $("#list_article");                //主体元素
    var state = 0;  
    var _srollPos = 0;

    var TPL = '<article>\
                    <header>\
                        <div class="article_state">{statusHTML}</div>\
                        <ul class="tbox">\
                            <li></li>\
                            <li><h5>{title}</h5>\
                                <p>{ctime}</p>\
                            </li>\
                            <li>{edit_trend}</li>\
                        </ul>\
                    </header>\
                    <section>\
                        <figure data-count="{image_url_count}张图片" {show_pic}><div>{imgs}</div></figure>\
                        <div>{content}</div>\
                        <a href="{comment_href}">查看全文</a>\
                    </section>\
                    <footer>\
                        <ul class="box">\
                            <li>\
                                <a href="javascript:;"  id="collect_{tid}" class="a_collect {collect_on}" {collect_click} ><span class="icons icons_collect" >&nbsp;</span><label>{collect}</label></a>\
                            </li>\
                            <li>\
                                <a href="{comment_href}" class="a_comment"><span class="icons icons_comment" >&nbsp;</span><label>{comment}</label></a>\
                            </li>\
                            <li>\
			                    <a href="javascript:;" id="praise_{tid}" class="a_like {praise_on}" {praise_click}><span class="icons icons_like"   >&nbsp;</span><label>{praise}</label></a>\
			                </li>\
			            </ul>\
			        </footer>\
			    </article>';

   var TPL_imgs = '<img src="{img_url}" data-src="{img_url}" data-gid="g{gi}" onload="preViewImg(this, event);"/>';
    
    $(window).scroll(function(){
        var pageSize = 15;
        var total = 1;
        if( Math.ceil(total/pageSize)<pageNum ){
              return false;
        }
        var srollPos = $(window).scrollTop();    //滚动条距顶部距离(页面超出窗口的高度)  
       if(srollPos<_srollPos){
            return;
        }else{
            _srollPos = srollPos;
        }
        totalheight = parseFloat($(window).height()) + parseFloat(srollPos);  
        if(!state && (($(document).height()-range) <= totalheight) ) {
            loading(true);
            state = 1;
            $.post('{$site_info.route_base}/ajax/ajaxtrendslist',{
                "app_id" : {$site_info.app_id},
                "uid"    : {$other_user_info.user_id},
                "page"   : pageNum
                },function(res){
                    loading(false);
                    if(res) {
                        var data = $.parseJSON(res);
                        html = iTemplate.makeList(TPL, data.rows, function(k,v){
	                        console.log(v);
	                        var gi = new Date().getTime();
	                        return {
	                             edit_trend:'<a href="{$site_info.route_base}/index/trendsrow?app_id='+v.app_id+'&tid='+v.tid+'&exa_trends='+data.shop.exa_trends+'" class="icons icons_edit">&nbsp;</a>',
	                             statusHTML : (function(){
	                                 if (v.status == "0"){
	                                    return '<span class="state1">审核通过</span>';
	                                 }else if (v.status == "1"){
	                                    return '<span class="state2">审核中</span>';
	                                 }else if(v.status == "2"){
	                                    return '<span class="state3">未通过</span>';
	                                 }
	                             })(),
	                             image_url_count: v.image_url[0]? v.image_url.length:0,
	                             show_pic:v.image_url[0]?'':'style="display:none;"',
	                             imgs: iTemplate.makeList(TPL_imgs, v.image_url, function(kk,vv){
	                                 return {
	                                      gi: gi 
	                                    }
	                             }),
	                             praise_on:"1" == (parseInt(v.ispraise) && ("0" != {$user_info.user_id}) )?'on':'',
	                             collect_on:"1" == (parseInt(v.iscollect) && ("0" != {$user_info.user_id}) )?'on':'',
	                             praise_click: "0" == {$user_info.user_id}?'onclick="return false;"': 'onclick="praiseTrends('+v.is_laud+', '+v.app_id+', '+v.tid+', '+{$user_info.user_id}+')"',
	                             collect_click: "0" == {$user_info.user_id}?'onclick="return false;"': 'onclick="collectTrends('+v.is_like+', '+v.app_id+', '+v.tid+', '+{$user_info.user_id}+')"',
	                             comment_href: "0" == {$user_info.user_id}?'javascript:;':  '{$site_info.route_base}/index/commentlist?app_id='+v.app_id+'&tid='+v.tid+'&uid='+v.uid,
	                             ctime:(function(vctime){
	                                    var f_ctime = new Date(vctime);
	                                    var arr = [];
	                                    arr.push( f_ctime.getFullYear() );
	                                    arr.push( "-" + (f_ctime.getMonth()+1 ) );
	                                    arr.push( "-" + f_ctime.getDate() );
	                                    arr.push( " " + f_ctime.getHours() );
	                                    arr.push( ":" + f_ctime.getMinutes() );
	                                    arr.push( ":" + f_ctime.getSeconds() );
	                                    return arr.join("");
	                                })(v.ctime*1000),
	                            comment_href: '{$site_info.route_base}/index/commentlist?app_id='+v.app_id+'&tid='+v.tid+'&uid='+v.uid
	                        }
	                    });
	                    main.append($(html) );
	                    pageNum ++;
	                    state = 0;
	                }else{
	                    loading(false);
	                    state = 0;
	                    alert("没有更多了...","1500");
	                }
            });
        }  
    });  
}); 


document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    WeixinJSBridge.call('hideOptionMenu');
});
</script>
</body>
</html>